<?php
    $menu = array(
        '/admin_slideshow'   => 'Početna strana',
		'/admin_pages'       => 'Stranice',
		'/admin_products'    => array( 'Proizvodi' => array(
            '/admin_products/categories' => 'Kategorije' 
        )),
		'/admin_receipes'    => 'Recepti',
		'/admin_news'        => 'Novosti',
		'/admin_partners'    => 'Proizvođači',
		'/admin_head_photos' => 'Slike u zaglavlju',
		'/admin_comments'    => 'Komentari klijenata'
	);
?><ul id="menu">
	<?php foreach($menu as $link=>$label): ?>
	<li>
		<?php 
			$r = Router::parse($link);
			$condition =  $r['controller'] == $this->request['controller'] && $r['action'] == $this->request['action'];
			if(!empty($this->request['pass'])) {
				$condition = $condition && $this->request['pass'] == $r['pass'];
			}
			
			$submenu = array();
			if(is_array($label)) {
				list($l) = array_keys($label);
				$submenu = $label[$l];
				$label = $l;
			}
		?>
		
		<?php if($condition): ?>
			<strong><?= $label ?></strong>
		<?php else: ?>
			<a href="<?=  $link ?>"><?=  $label ?></a>
		<?php endif; ?>
		
		<? if(!empty($submenu)): ?>
			<ul>
			<? foreach($submenu as $sublink=>$sublabel): ?>
			<li>
			<?php
				$r = Router::parse($sublink);
				$condition =  $r['controller'] == $this->request['controller'] && $r['action'] == $this->request['action'];
				if(!empty($this->request['pass'])) {
					$condition = $condition && $this->request['pass'] == $r['pass'];
				}
			?>
				<?php if($condition): ?>
					<strong><?= $sublabel ?></strong>
				<?php else: ?>
					<a href="<?=  $sublink ?>"><?=  $sublabel ?></a>
				<?php endif; ?>
			</li>
			<?php endforeach; ?>
			</ul>
		<? else: ?>
			
		<?php endif; ?>
	</li>
	<?php endforeach; ?>
</ul>